import { escloudHttp } from '@/utils/http/axios';
import { ErrorMessageMode } from '#/axios';

enum Api {
  getDeliveryReceiptDetail = '/eslogis-tps/shippingOrder/details/',
  getDeliveryDetailsApi = '/eslogis-tps/shippingOrder/detail/deliveryDetails/',
  getCost = '/eslogis-tps/freightInfo/getByShippingIds',
  postQuote = '/eslogis-tps/shippingOrderFlow/quote',
  postQuoteRecheck = '/eslogis-tps/shippingOrderFlow/quoteRecheck',
  postSchedule = '/eslogis-tps/shippingOrderFlow/schedule',
  postScheduleUpdate = '/eslogis-tps/shippingOrderFlow/scheduleUpdate',
  postOutBound = '/eslogis-tps/shippingOrderFlow/outBound',
  postInBound = '/eslogis-tps/shippingOrderFlow/inBound',
  postOutBoundRecheck = '/eslogis-tps/shippingOrderFlow/outBoundRecheck',
  postInBoundRecheck = '/eslogis-tps/shippingOrderFlow/inBoundRecheck',
  postSignFlow = '/eslogis-tps/shippingOrderFlow/signFlow',
  postSignRecheck = '/eslogis-tps/shippingOrderFlow/signRecheck',
  postShippingOrderFlow = '/eslogis-tps/shippingOrderFlow/accountApply',
  updateWhPrintInfo = '/eslogis-tps/shippingOrder/updateWhPrintInfo', //更新仓库打印信息

  getAreaList = '/eslogis-tps/shippingOrder/carrierQuote/getByMap', // 调度、合并调度、报价、合并报价头特殊处理
}

/**
 * 获取回单详情
 * @param Object data
 */
export function getDeliveryReceiptDetail(data: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.get<any>(
    {
      url: Api.getDeliveryReceiptDetail + data.id,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 查询发货单/退货单详情货物明细
 * @param Object data
 */
export function getDeliveryDetails(data: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.get<any>(
    {
      url: Api.getDeliveryDetailsApi + data.id,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 根据送货单id获取运费信息
 * @param Object data
 */
export function getCost(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.getCost,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 报价
 * @param Object data
 */
export function postQuote(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postQuote,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 报价复核
 * @param Object data
 */
export function postQuoteRecheck(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postQuoteRecheck,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 司机调度
 * @param Object data
 */
export function postSchedule(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postSchedule,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 司机变更
 * @param Object data
 */
export function postScheduleUpdate(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postScheduleUpdate,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 出库
 * @param Object data
 */
export function postOutBound(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postOutBound,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 入库
 * @param Object data
 */
export function postInBound(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postInBound,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 出库复核
 * @param Object data
 */
export function postOutBoundRecheck(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postOutBoundRecheck,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 入库复核
 * @param Object data
 */
export function postInBoundRecheck(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postInBoundRecheck,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 签收
 * @param Object data
 */
export function postSignFlow(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postSignFlow,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 签收复核
 * @param Object data
 */
export function postSignRecheck(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postSignRecheck,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 申请对账
 * @param Object data
 */
export function postShippingOrderFlow(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.postShippingOrderFlow,
      params,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 更新仓库打印信息
 * @param Object data
 */
export function updateWhPrintInfo(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.updateWhPrintInfo + '?id=' + params.id,
      params: params.whPrintInfo,
    },
    {
      errorMessageMode: mode,
    },
  );
}

/**
 * 获取头部
 * @param Object data
 */
export function getAreaList(params: any, mode: ErrorMessageMode = 'modal') {
  return escloudHttp.post<any>(
    {
      url: Api.getAreaList,
      params: params.shippingOrderIds,
    },
    {
      errorMessageMode: mode,
    },
  );
}
